<template>
    <div>
        <router-view v-slot="{ Component, route }">
            <transition name="slide-fade" mode="out-in">
                <keep-alive :max="5">
                    <component :is="Component" v-if="route.meta.keepAlive" :key="route.fullPath"></component>
                </keep-alive>
            </transition>
            <transition name="slide-fade" mode="out-in">
                <component :is="Component" v-if="!route.meta.keepAlive" :key="route.fullPath"></component>
            </transition>
        </router-view>
    </div>
</template>


<style type="text/css">
/*
  进入和离开动画可以使用不同
  持续时间和速度曲线。
*/
.slide-fade-enter-active {
    transition: all 0.3s ease-out;
}

.slide-fade-leave-active {
    transition: all 0.5s cubic-bezier(1, 0.5, 0.8, 1);
}

.slide-fade-enter-from,
.slide-fade-leave-to {
    transform: translateX(50px);
    opacity: 0;
}
</style>